#![allow(unused)]

use std::time::Duration;
use trpl::Html;

async fn html() {
    let text = trpl::get("http://www.baidu.com").await.text().await;
    let html = Html::parse(&text);
    let title = html.select_first("title").unwrap().text().next();
    println!("title: {:?}", title);
}
#[tokio::main]
async fn main() {
    trpl::spawn_task(async {
        trpl::sleep(Duration::from_secs(1)).await;
        println!("{}", "hello world");
    });
}

async fn channel() {
    let (sender, mut receiver) = trpl::channel();
    tokio::spawn(async move {
        sender.send("hello").unwrap();
        sender.send("world").unwrap();
    });

    tokio::spawn(async move {
        while let Some(msg) = receiver.recv().await {
            println!("msg: {:?}", msg);
        }
    });
}
// fn main() {
//     // 创建一个运行时，并执行future
//     let res = trpl::run(async { "hello world" });
//     println!("{}", res);
// }
